#!/usr/bin/env python
import sys
import PySimpleGUI as sg

"""
    Copyright 2023 PySimpleSoft, Inc. and/or its licensors. All rights reserved.

    Redistribution, modification, or any other use of PySimpleGUI or any portion thereof is subject to the terms of the PySimpleGUI License Agreement available at https://eula.pysimplegui.com.

    You may not redistribute, modify or otherwise use PySimpleGUI or its contents except pursuant to the PySimpleGUI License Agreement.
"""

# Usage of icons as base64 string and toolbar

house64 = ''
timer64 = ''
close64 = ''
psg64 = ''
cpu64 = ''
camera64 = ''
checkmark64 = ''
cookbook64 = ''
download64 = ''
github64 = ''
run64 = ''
storage64 = ''


def ShowMeTheButtons():
    # ------ Menu Definition ------ #
    menu_def = [['&File', ['&Open', '&Save', '&Properties', 'E&xit']],
                ['&Edit', ['&Paste', ['Special', 'Normal', ], 'Undo'], ],
                ['&Toolbar', ['---', 'Command &1', 'Command &2',
                              '---', 'Command &3', 'Command &4']],
                ['&Help', '&About...'], ]

    sg.set_options(auto_size_buttons=True,
            margins=(0, 0),
            button_color=sg.COLOR_SYSTEM_DEFAULT)

    toolbar_buttons = [[sg.Button('', image_data=close64[22:],button_color=('white', sg.COLOR_SYSTEM_DEFAULT), pad=(0,0), key='-close-'),
        sg.Button('', image_data=timer64[22:], button_color=('white', sg.COLOR_SYSTEM_DEFAULT), pad=(0, 0), key='-timer-'),
        sg.Button('', image_data=house64[22:], button_color=('white', sg.COLOR_SYSTEM_DEFAULT), pad=(0, 0), key='-house-'),
        sg.Button('', image_data=cpu64[22:], button_color=('white', sg.COLOR_SYSTEM_DEFAULT), pad=(0, 0), key='-cpu-'),
        sg.Button('', image_data=camera64[22:], button_color=('white', sg.COLOR_SYSTEM_DEFAULT), pad=(0, 0), key='-camera-'),
        sg.Button('', image_data=checkmark64[22:], button_color=('white', sg.COLOR_SYSTEM_DEFAULT), pad=(0, 0), key='-checkmark-'),
        sg.Button('', image_data=cookbook64[22:], button_color=('white', sg.COLOR_SYSTEM_DEFAULT), pad=(0, 0), key='-cookbook-'),
        sg.Button('', image_data=download64[22:], button_color=('white', sg.COLOR_SYSTEM_DEFAULT), pad=(0, 0), key='-download-'),
        sg.Button('', image_data=github64[22:], button_color=('white', sg.COLOR_SYSTEM_DEFAULT), pad=(0, 0), key='-github-'),
        sg.Button('', image_data=psg64[22:], button_color=('white', sg.COLOR_SYSTEM_DEFAULT), pad=(0, 0), key='-psg-'),
        sg.Button('', image_data=run64[22:], button_color=('white', sg.COLOR_SYSTEM_DEFAULT), pad=(0, 0), key='-run-'),
        sg.Button('', image_data=storage64[22:], button_color=('white', sg.COLOR_SYSTEM_DEFAULT), pad=(0, 0), key='-storage-'),
    ]]


    # layout = toolbar_buttons
    # ------ GUI Defintion ------ #
    layout = [[sg.Menu(menu_def, )],
              [sg.Frame('', toolbar_buttons, title_color='white',
                        background_color=sg.COLOR_SYSTEM_DEFAULT, pad=(0, 0))],
              [sg.Text('', size=(20, 8))],
              [sg.Text('Status Bar', relief=sg.RELIEF_SUNKEN,
                    size=(55, 1), pad=(0, 3), key='-status-')]
              ]

    window = sg.Window('Toolbar', layout)

    # ---===--- Loop taking in user input --- #
    while True:
        button, value = window.read()
        print(button)
        if button in ('-close-', 'Exit') or button is None:
            break       # exit button clicked
        elif button == '-timer-':
            pass        # add your call to launch a timer program
        elif button == '-cpu-':
            pass        # add your call to launch a CPU measuring utility


if __name__ == '__main__':
    ShowMeTheButtons()
